import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

const router = new Router({
  routes: [
    r("/", "", "MainLayout", [
      // 数据罗盘
      r("", "dashboard", "account/Dashboard"),

      // 店铺模块
      r("shop", "shop", "shop/index"),
      r("addShop", "addShop", "shop/addShop"),

      // 会员模块
      r("member", "member", "member/index"),

      // 卡券模块
      r("coupon", "coupon", "coupon/index"),

      // 积分模块
      r("integral", "integral", "integral/index"),

      // 营销模块
      r("market", "market", "market/index"),

      // 系统模块
      r("system", "system", "system/index"),

      // 账户模块
      r("userCenter", "userCenter", "account/userCenter")
    ]),

    r("/login", "login", "account/Login"),
    r("/register", "register", "account/Register"),
    r("*", "404", "404")
  ]
});

export default router;

function r(path, name, component, children) {
    return { 
        path: path,
        name: name,
        component: () => import("./views/" + component + ".vue"),
        children: children
    };
}
